package com.zhiyou.brank.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou.brank.mapper.FlyGrad;
import com.zhiyou.brank.service.FlyClassService;
import com.zhiyou.brank.service.FlyGradService;
import com.zhiyou.brank.service.FlyScoreService;
import com.zhiyou.model.FYGrad;
import com.zhiyou.model.FyClass;
import com.zhiyou.model.FyScore;

@Service
public class FlyGradServiceImpl implements FlyGradService{
@Autowired
FlyGrad flyGrad;
@Autowired
FlyScoreService flyScoreService;
@Autowired
FlyClassService flyClassService;
	public List<FyScore> selectGradOne(Integer class_id,Integer exam_id) {

		FyClass selectFlyClassOne = flyClassService.selectFlyClassOne(class_id);
		System.out.println("学生"+selectFlyClassOne);
		List<FyScore> selectScoreOne1 = new ArrayList<FyScore>();	
		for (int i = 0; i < selectFlyClassOne.getFyStudents().size(); i++) {
			

			//个人单科成绩
			List<FyScore> selectScoreOne= flyScoreService.selectScoreOne(selectFlyClassOne.getFyStudents().get(i).getStudent_id(), exam_id);
			
			System.out.println("第一"+selectScoreOne);
			for (int j = 0; j < selectScoreOne.size(); j++) {
				FyScore selectScoreTwo = flyScoreService.selectScoreTwo(selectFlyClassOne.getFyStudents().get(i).getStudent_id(), exam_id);
				FyScore	score1=flyScoreService.selectScoreTwo(selectFlyClassOne.getFyStudents().get(i).getStudent_id(), exam_id);			
				FyScore fyScore = selectScoreOne.get(j);			
				fyScore.setScore_sum(selectScoreTwo.getScore_sum());
				if (score1.getStudent_id()==fyScore.getStudent_id()) {
					fyScore.setScore_sum(score1.getScore_sum());				
				}		
				selectScoreOne1.add(fyScore);			
			}
		}
		return selectScoreOne1;
	}
	public FYGrad selectGradTwo(Integer class_id, Integer exam_id, Integer course_id) {	
		return flyGrad.selectGradTwo(class_id, exam_id, course_id);
	}

}
